package com.liao.member.controller;

import com.liao.common.entity.member.UserBehaviorEntity;
import com.liao.common.utils.PageUtils;
import com.liao.member.service.UserBehaviorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 用户行为埋点数据
 *
 * @author liao
 * @email 2858015963@qq.com
 * @date 2025-03-10 19:27:53
 */
@RestController
@RequestMapping("member/userbehavior")
public class UserBehaviorController {
    @Autowired
    private UserBehaviorService userBehaviorService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public PageUtils<UserBehaviorEntity> list(@RequestParam Map<String, Object> params) {
        return userBehaviorService.queryPage(params);

    }


    /**
     * 信息
     */
    @RequestMapping("/info/{behaviorId}")
    public UserBehaviorEntity info(@PathVariable("behaviorId") Long behaviorId) {
        return userBehaviorService.getById(behaviorId);

    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public void save(@RequestBody UserBehaviorEntity userBehavior) {
        userBehaviorService.save(userBehavior);
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public void update(@RequestBody UserBehaviorEntity userBehavior) {
        userBehaviorService.updateById(userBehavior);
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public void delete(@RequestBody Long[] behaviorIds) {
        userBehaviorService.removeByIds(Arrays.asList(behaviorIds));
    }

}
